<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="dao.UserDao" %>
<%@ page import="entity.User" %>
    <%
    	request.setCharacterEncoding("utf-8");
    	String username=(String)request.getParameter("username");
    	String password=(String)request.getParameter("password");
    	
    	if(username==null|| "".equals(username)|| password==null|| "".equals(password)){
    		response.sendRedirect("index.jsp?code=1000");
    		return;
    	}
    	UserDao ud=new UserDao();
    	User user=ud.findUserByName(username);
    	if(user!=null && user.getPassword().equals(password)){
    		//System.out.println("登陆成功！");
    		session.setAttribute("user",username);
    		response.sendRedirect("home.jsp");
    	}else{
    		//System.out.println("登陆失败！");
    		response.sendRedirect("index.jsp?code=1002");
    	}
    %>